import React, { Component } from 'react';

import { connect } from 'react-redux';
import { getNewsList } from '../store/news';

class News extends Component {
    UNSAFE_componentWillMount() {
        this.props.dispatch(getNewsList());
    }
    render() {
        return (
            <div style={{border:'1px solid #CCC',padding:10,borderRadius:4,marginBottom:10}}>
                <h1>新闻管理</h1>
                <hr/>
                <ol>
                    {
                        this.props.newsList.map(item => (<li key={item.id}>{item.title}</li>))
                    }
                </ol>
            </div>
        )
    }
}
export default connect(function (state) {
    return {
        newsList: state.news.newsList
    }
})(News);
